<?php

namespace think\wework\Api;

use think\wework\Abstracts\WeworkApiWithToken;

class Menu extends WeworkApiWithToken
{
    private static ?Menu $instance = null;
    public static function getInstance(): Menu
    {
        if(!self::$instance instanceof Menu) {
            self::$instance = new self();
        }
        return self::$instance;
    }
    /**
     * 创建菜单
     *
     * @param array $json
     * @return array
     */
    public function create(array $json): array
    {
        $query = ['agentid' => $this->agentId];
        return $this->httpClient->post('menu/create', array_merge(compact('json'), compact('query')))->toArray();
    }

    /**
     * 获取菜单
     *
     * @return array
     */
    public function get(): array
    {
        $query = ['agentid' => $this->agentId];
        return $this->httpClient->get('menu/get', compact('query'))->toArray();
    }

    /**
     * 删除菜单
     *
     * @return array
     */
    public function delete(): array
    {
        $query = ['agentid' => $this->agentId];
        return $this->httpClient->get('menu/delete', compact('query'))->toArray();
    }
}
